<template>
  <div>
    <el-dialog title="会员修改" :visible.sync="user.isshow">
      <el-form :model="form">
        <el-form-item label="手机号" label-width="120px">
          <el-input v-model="form.phone" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="昵称" label-width="120px">
          <el-input v-model="form.nickname" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="密码" label-width="120px">
          <el-input v-model="form.password" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="状态" label-width="120px">
          <el-switch v-model="form.status" :active-value="1" :inactive-value="2"></el-switch>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="edit">编辑</el-button>
        <el-button @click="cancle">取消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { reqmemberinfo, reqmemberedit } from "../../../request/api";
import { successAlert } from "../../../utils/alert";
import { mapGetters, mapActions } from "vuex";
export default {
  props: ["user"],
  data() {
    return {
      form: {
        uid: "",
        nickname: "",
        phone: "",
        password: "",
        status: 1,
      },
    };
  },
  methods: {
    ...mapActions({
      reqList: "member/reqList",
    }),
    getOne(uid) {
      reqmemberinfo({
        uid: uid,
      }).then((res) => {
        this.form = res.data.list;
        this.form.password = "";
      });
    },
    edit() {
      reqmemberedit(this.form).then((res) => {
        if (res.data.code === 200) {
          successAlert(res.data.msg);
          // 刷新列表
          this.reqList();
          this.cancle();
        }
      });
    },
    cancle() {
      this.user.isshow = false;
    },
    // empty() {
    //   this.form = {
    //     uid: "",
    //     nickname: "",
    //     phone: "",
    //     password: "",
    //     status: 1,
    //   };
    // },

    // closed(){

    // }
  },
};
</script>

<style>
</style>